package com.zx.controller;

import com.zx.entity.Menu;
import com.zx.service.MenuInte;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 程仟磊
 * @date 2021/7/26
 */
@Controller
public class Menuc {
    @Resource
    private MenuInte menuInte;
    //查找一级菜单
    @ResponseBody
    @RequestMapping("/findAllFirstMenu")
    public List findAllFirstMenu(){
     return menuInte.findAllFirstMenu();
    }
    @ResponseBody
    //二级菜单，通过父菜单
    @RequestMapping("/findTwoMenuByParent")
    public List findTwoMenuByParent(String mid){
        return menuInte.findTwoMenuByParent(mid);
    }
    //修改二级菜单
    @RequestMapping("/updateMenuById")
    public String updateMenuById(Menu menu){
      int i= menuInte.updateMenuById(menu);
      return "list_menu";
    }
    //删除二级菜单
    @ResponseBody
    @RequestMapping("/deleteMenu")
    public String deleteMenu(String mid){
        int i=menuInte.deleteMenu(mid);
        if (i==1){
            return "true";
        }else {
            return "false";
        }
    }
    //删除一级菜单
    @ResponseBody
    @RequestMapping("/deleteMenuF")
    public String deleteMenuF(String mid){
        int i=menuInte.deleteMenuF(mid);
        if (i==1){
            return "true";
        }else {
            return "false";
        }
    }
    //添加菜单
    @RequestMapping("/addMenu")
    public String addMenu(Menu menu){
        int i=menuInte.addMenu(menu);
        if (i==1){
            return "list_menu";
        }else {
            return "500";
        }
    }

}
